IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'CreatorsGetBySaga')
	BEGIN
		DROP  Procedure  CreatorsGetBySaga
	END

GO

CREATE Procedure CreatorsGetBySaga
@SagaID INT
AS
Select
c.CreatorID,
c.DefaultSagaID,
c.IsBrowser,
c.CanADD,
asp.UserName,
coalesce(sr.RoleName,'Browser') AS RoleName,
coalesce(sc.SagaRoleID,1) AS SagaRoleID
From Creator c
Left Join SagaCreators sc On sc.CreatorID = c.CreatorID and sc.SagaID = @SagaID
Left Join SagaRoles sr On sr.SagaRoleID = sc.SagaRoleID 
Join aspnet_Users asp On asp.UserID = c.UserID

GO


